/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.jclip.examples.helloworld;


import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.HashMap;

import javax.swing.JMenu;

import org.jclip.runtime.JavaClientPage;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.Rectangle;
import java.awt.Color;
import javax.swing.SwingConstants;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.Font;
import javax.swing.JTextField;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.JScrollPane;
import java.awt.Dimension;
import java.awt.BorderLayout;
/**
 *
 * @author kissmyirish
 */
public class DoodleTime extends JavaClientPage {

		protected HashMap<String,Object> hm = new HashMap<String, Object>();
		protected JMenu menu = new JMenu("Time");
		protected String pageTitle = "MyDoodle.com Time Slots";
    /**
     * Creates new form DoodleTime
     */
    public DoodleTime(HashMap<String,Object> hm) {
    	super(hm);    		
    	this.hm=hm;
    	setBackground(new Color(255, 255, 255));
    	setBounds(new Rectangle(100, 100, 800, 600));
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel1 = new javax.swing.JPanel();
        upperPanel = new javax.swing.JPanel();
        doodle = new javax.swing.JLabel();
        signIN = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        backButton = new javax.swing.JButton();
        nextButton = new javax.swing.JButton();

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        upperPanel.setBackground(new java.awt.Color(255, 255, 255));

        doodle.setFont(new java.awt.Font("Arial Black", 1, 36)); // NOI18N
        doodle.setForeground(new java.awt.Color(51, 102, 255));
        doodle.setText("MyDoodle");

        signIN.setBackground(new java.awt.Color(255, 255, 255));
        signIN.setForeground(new java.awt.Color(0, 102, 204));
        signIN.setText("Sign in");

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(0, 102, 204));
        jLabel1.setText("Schedule an event");

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(0, 102, 204));
        jLabel2.setText("1. General >");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel3.setText("2. Time proposals >");

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(102, 102, 102));
        jLabel4.setText("3. Settings >");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(102, 102, 102));
        jLabel5.setText("4. Invite");

        javax.swing.GroupLayout upperPanelLayout = new javax.swing.GroupLayout(upperPanel);
        upperPanelLayout.setHorizontalGroup(
        	upperPanelLayout.createParallelGroup(Alignment.LEADING)
        		.addGroup(upperPanelLayout.createSequentialGroup()
        			.addGap(20)
        			.addGroup(upperPanelLayout.createParallelGroup(Alignment.LEADING)
        				.addGroup(upperPanelLayout.createSequentialGroup()
        					.addComponent(jLabel1)
        					.addContainerGap())
        				.addGroup(Alignment.TRAILING, upperPanelLayout.createSequentialGroup()
        					.addComponent(doodle)
        					.addPreferredGap(ComponentPlacement.RELATED, 538, Short.MAX_VALUE)
        					.addComponent(signIN)
        					.addGap(55))
        				.addGroup(upperPanelLayout.createSequentialGroup()
        					.addComponent(jLabel2)
        					.addGap(18)
        					.addComponent(jLabel3)
        					.addGap(18)
        					.addComponent(jLabel4)
        					.addGap(18)
        					.addComponent(jLabel5)
        					.addGap(0, 438, Short.MAX_VALUE))))
        );
        upperPanelLayout.setVerticalGroup(
        	upperPanelLayout.createParallelGroup(Alignment.TRAILING)
        		.addGroup(upperPanelLayout.createSequentialGroup()
        			.addContainerGap(31, Short.MAX_VALUE)
        			.addGroup(upperPanelLayout.createParallelGroup(Alignment.LEADING)
        				.addComponent(signIN)
        				.addComponent(doodle, GroupLayout.PREFERRED_SIZE, 40, GroupLayout.PREFERRED_SIZE))
        			.addGap(18)
        			.addComponent(jLabel1)
        			.addGap(18)
        			.addGroup(upperPanelLayout.createParallelGroup(Alignment.BASELINE)
        				.addComponent(jLabel2)
        				.addComponent(jLabel3)
        				.addComponent(jLabel4)
        				.addComponent(jLabel5))
        			.addContainerGap())
        );
        upperPanel.setLayout(upperPanelLayout);

        jPanel2.setBackground(new java.awt.Color(215, 234, 253));
        jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 5));

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jLabel6.setText("Time");

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel7.setText("Enter any number of time proposals for each day. If you do not enter an actual time span, ");

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel8.setText("the proposed date is shown as all-day.");

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel9.setForeground(new java.awt.Color(0, 102, 204));
        jLabel9.setText("Enable time-zone support");

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel10.setText("Time 1");

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel11.setText("Time 2");

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel12.setText("Time 3");

        backButton.setText("Back");
        backButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backButtonActionPerformed(evt);
            }
        });

        nextButton.setText("Next");
        nextButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nextButtonActionPerformed(evt);
            }
        });
        
        panel = new JPanel();
        panel.setBackground(new Color(215,234,253));
        panel.setLayout(null);
        
        int counter = Integer.parseInt((String) hm.get("Date counter"));
        System.out.println(hm.toString()+counter);
        
        for(int i=1; i<counter; i++){
        	JLabel date = (JLabel) hm.get("Date "+i);
        	date.setFont(new java.awt.Font("Tahoma", 0, 14));
        	date.setBounds(0, 22*(i-1), 108, 14);
        	date.setVerticalTextPosition(SwingConstants.BOTTOM);
        	date.validate();
        	panel.add(date);
        }
        
        JPanel panel_1 = new JPanel();
        panel_1.setBackground(new Color(215,234,253));
        
        
        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2Layout.setHorizontalGroup(
        	jPanel2Layout.createParallelGroup(Alignment.LEADING)
        		.addGroup(jPanel2Layout.createSequentialGroup()
        			.addContainerGap()
        			.addGroup(jPanel2Layout.createParallelGroup(Alignment.TRAILING)
        				.addGroup(jPanel2Layout.createParallelGroup(Alignment.LEADING)
        					.addComponent(jLabel6)
        					.addComponent(jLabel7)
        					.addComponent(jLabel8)
        					.addComponent(jLabel9)
        					.addGroup(jPanel2Layout.createSequentialGroup()
        						.addGap(18)
        						.addComponent(backButton, GroupLayout.PREFERRED_SIZE, 66, GroupLayout.PREFERRED_SIZE)
        						.addPreferredGap(ComponentPlacement.RELATED)
        						.addComponent(nextButton, GroupLayout.PREFERRED_SIZE, 67, GroupLayout.PREFERRED_SIZE)))
        				.addGroup(jPanel2Layout.createSequentialGroup()
        					.addComponent(panel, GroupLayout.PREFERRED_SIZE, 170, GroupLayout.PREFERRED_SIZE)
        					.addPreferredGap(ComponentPlacement.RELATED, 58, Short.MAX_VALUE)
        					.addGroup(jPanel2Layout.createParallelGroup(Alignment.LEADING)
        						.addGroup(jPanel2Layout.createSequentialGroup()
        							.addComponent(jLabel10)
        							.addGap(110)
        							.addComponent(jLabel11)
        							.addGap(116)
        							.addComponent(jLabel12))
        						.addComponent(panel_1, GroupLayout.PREFERRED_SIZE, 481, GroupLayout.PREFERRED_SIZE))))
        			.addGap(113))
        );
        jPanel2Layout.setVerticalGroup(
        	jPanel2Layout.createParallelGroup(Alignment.LEADING)
        		.addGroup(jPanel2Layout.createSequentialGroup()
        			.addContainerGap()
        			.addComponent(jLabel6)
        			.addPreferredGap(ComponentPlacement.UNRELATED)
        			.addComponent(jLabel7)
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addComponent(jLabel8)
        			.addGap(43)
        			.addComponent(jLabel9)
        			.addGap(49)
        			.addGroup(jPanel2Layout.createParallelGroup(Alignment.BASELINE)
        				.addComponent(jLabel10)
        				.addComponent(jLabel11)
        				.addComponent(jLabel12))
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addGroup(jPanel2Layout.createParallelGroup(Alignment.LEADING)
        				.addGroup(jPanel2Layout.createSequentialGroup()
        					.addComponent(panel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        					.addGap(18))
        				.addGroup(jPanel2Layout.createSequentialGroup()
        					.addComponent(panel_1, GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
        					.addGap(90)))
        			.addGroup(jPanel2Layout.createParallelGroup(Alignment.BASELINE)
        				.addComponent(backButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        				.addComponent(nextButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        			.addContainerGap())
        );
        DefaultTableModel model = new DefaultTableModel(
            	new Object[][] {
                		{null, null, null},
                	},
                	new String[] {
                		"Time 1", "Time 2", "Time 3"
                	}
                );
        for(int i=1; i<counter-1; i++){
        	model.addRow(new Object[]{null,null,null});
        }
        GridBagLayout gbl_panel_1 = new GridBagLayout();
        gbl_panel_1.columnWidths = new int[]{481, 0};
        gbl_panel_1.rowHeights = new int[]{130, 34, 0};
        gbl_panel_1.columnWeights = new double[]{0.0, Double.MIN_VALUE};
        gbl_panel_1.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
        panel_1.setLayout(gbl_panel_1);
        
        panel_3 = new JPanel();
        GridBagConstraints gbc_panel_3 = new GridBagConstraints();
        gbc_panel_3.fill = GridBagConstraints.BOTH;
        gbc_panel_3.insets = new Insets(0, 0, 5, 0);
        gbc_panel_3.gridx = 0;
        gbc_panel_3.gridy = 0;
        panel_1.add(panel_3, gbc_panel_3);
        panel_3.setLayout(new BorderLayout(0, 0));
        panel_3.setBackground(new Color(215,234,253));
        
        table = new JTable();
        panel_3.add(table, BorderLayout.NORTH);
        table.setRowHeight(22);
        table.setRowSelectionAllowed(false);
        table.setRowMargin(5);
        table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
        table.setIntercellSpacing(new Dimension(5, 5));
        table.setFillsViewportHeight(true);
        table.setFont(new Font("Tahoma", Font.PLAIN, 14));
        table.setBounds(new Rectangle(0,11,0,0));
        table.setModel(model);
        
        JPanel panel_2 = new JPanel();
        panel_2.setBackground(new Color(215,234,253));
        GridBagConstraints gbc_panel_2 = new GridBagConstraints();
        gbc_panel_2.anchor = GridBagConstraints.NORTH;
        gbc_panel_2.fill = GridBagConstraints.HORIZONTAL;
        gbc_panel_2.gridx = 0;
        gbc_panel_2.gridy = 1;
        panel_1.add(panel_2, gbc_panel_2);
        panel_2.setLayout(new BorderLayout(0, 0));
        
        JLabel lblNewLabel_2 = new JLabel("Add further time slots");
        lblNewLabel_2.setForeground(Color.BLUE);
        lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 14));
        panel_2.add(lblNewLabel_2, BorderLayout.WEST);
        
        lblCopyAndPaste = new JLabel("Copy and paste first row");
        lblCopyAndPaste.setForeground(Color.BLUE);
        lblCopyAndPaste.setFont(new Font("Tahoma", Font.PLAIN, 14));
        panel_2.add(lblCopyAndPaste, BorderLayout.SOUTH);
        
        
        jPanel2.setLayout(jPanel2Layout);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1Layout.setHorizontalGroup(
        	jPanel1Layout.createParallelGroup(Alignment.LEADING)
        		.addGroup(Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
        			.addGroup(jPanel1Layout.createParallelGroup(Alignment.TRAILING)
        				.addGroup(jPanel1Layout.createSequentialGroup()
        					.addGap(10)
        					.addComponent(jPanel2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        				.addComponent(upperPanel, GroupLayout.DEFAULT_SIZE, 720, Short.MAX_VALUE))
        			.addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
        	jPanel1Layout.createParallelGroup(Alignment.LEADING)
        		.addGroup(jPanel1Layout.createSequentialGroup()
        			.addComponent(upperPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addComponent(jPanel2, GroupLayout.DEFAULT_SIZE, 521, Short.MAX_VALUE))
        );
        jPanel1.setLayout(jPanel1Layout);

        jScrollPane1.setViewportView(jPanel1);
        jScrollPane1.getVerticalScrollBar().setUnitIncrement(16);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 661, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 616, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_backButtonActionPerformed

    private void nextButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextButtonActionPerformed
    }//GEN-LAST:event_nextButtonActionPerformed
    
    public JMenu getMenus()
    {
    	return menu;
    }
    
    public String getTitle()
    {
    	return pageTitle;
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton backButton;
    private javax.swing.JLabel doodle;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton nextButton;
    private javax.swing.JLabel signIN;
    private javax.swing.JPanel upperPanel;
    private JPanel panel;
    private JLabel lblNewLabel;
    private JLabel lblNewLabel_1;
    private JTable table;
    private JLabel lblCopyAndPaste;
    private JPanel panel_3;
}
